package com.tckdq.tcc.web.controller;

import com.tckdq.tcc.domain.SmsCodeDto;
import com.tckdq.tcc.result.JsonResult;
import com.tckdq.tcc.service.iVerifyCodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.io.IOException;

@RestController
@RequestMapping("/verifycode")
public class RegisterController {


    @Autowired
    private iVerifyCodeService VerifyCodeService;


    @GetMapping("/imageCode/{imageCodeKey}")
    public JsonResult imgVerifyCode(@PathVariable("imageCodeKey")String imageCodeKey) throws IOException {

            String base64Str = VerifyCodeService.getImgCode(imageCodeKey);
            return JsonResult.success(base64Str);

    }

    /*/common/verifycode/sendSmsCode*/

    @PostMapping("/sendSmsCode")
    public JsonResult smsCode(@RequestBody @Valid SmsCodeDto smsCodeDto) {
        VerifyCodeService.smsCode(smsCodeDto);
        return new JsonResult();

    }
}
